package cn.xfdzx.android.apps.shop.adapter;

import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import cn.xfdzx.android.apps.shop.R;
import cn.xfdzx.android.apps.shop.bean.OrderProcessBeen;
import cn.xfdzx.android.apps.shop.util.EmptyUtil;
import cn.xfdzx.android.apps.shop.util.ImageGlideUtil;

/**
 * Creator: zf.
 * Date: 2020/7/14.
 * Description:售后服务商品列表适配器.
 */
public class AfterServiceProcessGoodsListAdapter extends BaseQuickAdapter<OrderProcessBeen.DataBean.ApplyGoodsBean, BaseViewHolder>  {
    private OnItemOnClickListener onItemOnClickListener;
    private List<OrderProcessBeen.DataBean.ApplyGoodsBean> cartInfo;//商品列表 = new ArrayList<>();//商品列表
    public AfterServiceProcessGoodsListAdapter(@Nullable List<OrderProcessBeen.DataBean.ApplyGoodsBean> data) {
        super(R.layout.item_afterserviceprocess_goods, data);
    }

    @Override
    public void setData(int index, @NonNull OrderProcessBeen.DataBean.ApplyGoodsBean data) {
        super.setData(index, data);
    }


    @Override
    protected void convert(final BaseViewHolder viewHolder, final OrderProcessBeen.DataBean.ApplyGoodsBean date) {

        ImageView imageView = viewHolder.getView(R.id.iv_shop_picture);
        if (EmptyUtil.isNotEmpty(date)){
            viewHolder.setText(R.id.tv_shop_goods_name,date.getGoods_name())
                    .setText(R.id.tv_shop_goods_price,"¥"+date.getCart_goods_price())
                    .setText(R.id.tv_goods_count,"x"+date.getGoods_apply_num());

            ImageGlideUtil.loadImage(mContext,imageView,date.getGoods_img());
        }

    }
    public void clearDatas(){
        mData.clear();
        notifyDataSetChanged();
    }
    public void refreshDatas(List<OrderProcessBeen.DataBean.ApplyGoodsBean> list){
        this.cartInfo = list;
        super.replaceData(list);
    }

    public void setItemAddMoveListener(OnItemOnClickListener listener){
        this.onItemOnClickListener = listener;
    }

    public interface OnItemOnClickListener {
        void onItemAddMoveClick(int position, int count, OrderProcessBeen.DataBean.ApplyGoodsBean date);
    }

}
